package com.tanhua.server.service;

import com.tanhua.dubbo.api.UserLocationApi;
import com.tanhua.model.vo.ErrorResult;
import com.tanhua.server.exception.BusinessException;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;

    /*上报(更新)地理位置*/
    public void updateLocation(Double longitude, Double latitude, String address) {
        //获取当前用户信息
        Long userId = UserHolder.getUserId();
        //调用API进行地理位置的上报
        Boolean result = userLocationApi.updateLocation(userId, longitude, latitude, address);
        if (!result){
            throw  new BusinessException(ErrorResult.error());
        }

    }
}
